{include file="public/mobileheader"}
<style>
    body{
        padding-top: 50px;
        background-color: white;
    }
    .mui-icon{
        display: inline-block;
        text-align: center;
    }


    .user-img {
        width: 24px;
        height: 24px;
        border-radius: 12px;
        transform: translate(0px, 5px);
    }
    .order-num{
        margin-top: 9px;
        font-size: 20px;
        font-weight: 500;
        color: red;
    }
    .mui-table-view-cell{
        padding: 11px 24px;
    }
    .mui-btn-block{
        padding: 7px 0;
        margin-top: 3em;
    }
</style>

    <body>
        <header class="mui-bar mui-bar-nav">
            <a onclick="window.history.go(-1)" class="mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title">订单详情页</h1>
        </header>

        <div style="text-align: center;">
            <img class="user-img" src="{$list['headimgurl']}">
            <span class="agent-name">{$list['name']}</span>
            <p class="order-num">{$list['num']}</p>
            <p class="order-text">订购数量（个）</p>
        </div>

        <ul class="mui-table-view">
            <li class="mui-table-view-cell">订单创建日期<span class="mui-pull-right">{$list['create_time']}</span></li>
            <li class="mui-table-view-cell">订单编号<span class="mui-pull-right">{$list['order_num']}</span></li>
            <li class="mui-table-view-cell">
                <a href="#" style="padding: 11px 15px;" class="mui-navigate-right">
                    代理商信息详情
                </a>
            </li>
        </ul>
        <form>
            <input type="hidden" name="order_num" value="{$list['order_num']}">
            <input type="hidden" name="num" value="{$list['num']}">
            <input type="hidden" name="name" value="{$list['name']}">
            <input type="hidden" name="id" value="{$list['id']}">
        </form>

        {if condition="$list['is_delivery'] == 1"}
            <button type="button" class="mui-btn mui-btn-warning mui-btn-block">已发货，处理日期</button>
            <p style="text-align: center;">{$list['update_time']}</p>
        {else /}
            {if condition="$list['num'] lt ($total_key-$is_active)"}
                <button type="button" id="purchase" class="mui-btn mui-btn-success mui-btn-block">确认发放激活码</button>
            {else /}
                <div style="text-align: center">
                    <button type="button" class="mui-btn mui-btn-warning mui-btn-block">库存激活码数量不够</button>
                    <p>您目前拥有激活码：<span style="color:red;">{$total_key}</span>（个）</p>
                    <p>已被激活：<span style="color:red;">{$is_active}</span>（个）</p>
                    <p>目前自由的激活码数量已经不足以授权下级代理</p>
                    <a href="{:url('index')}"><span>请先点击此处去订货</span></a>
                </div>
            {/if}
        {/if}
        {include file="public/nav"}
    </body>

{include file="public/mobilefooter"}
<script>
    $('#purchase').click(function() {
        var params  = {
            url : "{:url('')}",
            data: $('form').serialize(),
            type: 'post',
            sCallback:function(res){
                dialog.confirm(res.msg, "{:url('hadDelivery')}");
            }
        };
        common.request(params);
    });
</script>

</html>